package com.dazhewan.project.properties;

import java.awt.*;

/**
 * @author: zheng
 * @code date: 2022/10/10
 * @code className: ContainerSize
 * @code description:
 */
public class ContainerSize {
    private static ContainerSize containerSize = new ContainerSize();
    private Integer width;
    private Integer height;
    private Integer localx;
    private Integer localy;
    private int windowWidth;
    private int windowHeight;

    public static ContainerSize getContainerSize() {
        return containerSize;
    }

    private ContainerSize() {
        Toolkit tk = Toolkit.getDefaultToolkit();
        //得到屏幕的尺寸
        Dimension screen = tk.getScreenSize();
        this.windowWidth = screen.width;
        this.windowHeight = screen.height;
    }

    public int getWidth() {
        if (width == null)
            return windowWidth / 2;
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public int getHeight() {
        if (height == null)
            return windowHeight / 2;
        return height;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public int getLocalx() {
        if (localx == null)
            return (windowWidth - getWidth())/2;
        return localx;
    }

    public void setLocalx(int localx) {
        this.localx = localx;
    }

    public int getLocaly() {
        if (localy == null)
            return (windowHeight - getHeight())/2;
        return localy;
    }

    public void setLocaly(int localy) {
        this.localy = localy;
    }

    public int getWindowWidth() {
        return windowWidth;
    }

    public int getWindowHeight() {
        return windowHeight;
    }
}
